package cn.gok.springsecuritydemo01.contoller;

import org.springframework.security.authentication.RememberMeAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: chen fan
 * @since: 2022/11/17 15:40
 * @description:
 */
@RestController
public class TestController {


    @RequestMapping("/hello")
    public String hello(Authentication authentication){

        if (RememberMeAuthenticationToken.class.isAssignableFrom(authentication.getClass())){
            throw new RememberMeAuthenticationException("认证信息来源于RememberMe,请重新登录");
        }

        return "hello Spring Security";
    }


    @RequestMapping("/hello1")
    public String hello1(){
        return "hello world";
    }



    @RequestMapping("/hello2")
    public String hello2(){
        return "hello!!!";
    }
}
